import { apiClient } from "./api";

export const orderService = {
  // === 订单相关 ===
  getAllOrders: () => apiClient.get("/orders"),
  getOrderById: (id) => apiClient.get(`/orders/${id}`),
  createOrder: (order) => apiClient.post("/orders", order),
  deleteOrder: (id) => apiClient.delete(`/orders/${id}`),
  getOrdersByCustomer: (customerId) =>
    apiClient.get(`/orders/customer/${customerId}`),

  // === 订单项相关 ===
  saveOrderItems: (items) => apiClient.post("/order-items/batch", items),
  getOrderItemsByOrderId: (orderId) =>
    apiClient.get(`/order-items/order/${orderId}`),

  // === 地址相关 ===
  saveAddress: (address) => apiClient.post("/address", address),
  getAddressByOrderId: (orderId) => apiClient.get(`/address/order/${orderId}`),
};
